/**
 * @公司:公约树
 * @位置:苏州
 * @Classname positionVarModel
 * @Date 2022-06-01 下午 12:26
 * @Created by hanWanLu
 * @auther 中文:韩万路
 */


package com.animeJava.mode;

/**
 * 方向变量
 */
public class PositionVarModel {

    private double x ;
    private double y ;

    public PositionVarModel() {
    }

    public PositionVarModel(double x, double y) {
        this.x = x;
        this.y = y;
    }

    /**
     * 算出到的变量百分比的位置
     * @param toPosition
     * @param thePercentage
     * @return
     */
    public PositionVarModel toComputed(PositionVarModel toPosition , double thePercentage){
        if(toPosition != null && thePercentage <= 1 && thePercentage >= 0){
            double x = (toPosition.getX() - this.x)*thePercentage + this.x;
            double y = (toPosition.getY() - this.y)*thePercentage + this.y;
            return new PositionVarModel(x,y);
        }
        return null;
    }

    public double getX() {
        return x;
    }

    public void setX(double x) {
        this.x = x;
    }

    public double getY() {
        return y;
    }

    public void setY(double y) {
        this.y = y;
    }
}
